package cz.proks.easyhelpdesk.gae.core.db;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import cz.proks.easyhelpdesk.api.HelpdeskApi;
import cz.proks.easyhelpdesk.api.config.Configuration;
import cz.proks.easyhelpdesk.api.exception.ApiException;
import cz.proks.easyhelpdesk.api.model.Helpdesk;

@Component(Configuration.Core.DB.HELPDESK_API)
public class HelpdeskApiImpl extends BaseApiImpl<Helpdesk> implements HelpdeskApi{
	private final Logger log = LoggerFactory.getLogger(getClass());
	
	@Autowired
	@Qualifier(Configuration.DB.HELPDESK_API)
	private HelpdeskApi dbApi;

	@Override
	protected HelpdeskApi getDbApi() {
		return dbApi;
	}

    @Override
    public List<Helpdesk> listForUser(Long userId) throws ApiException {
        log.debug("listForUser():: Start with userId '{}'", userId);
        
        List<Helpdesk> entityList = getDbApi().listForUser(userId);        
        
        log.debug("listForUser():: Exit with {} entities", entityList != null ? entityList.size() : null);
        return entityList;
    }		
}